package com.cuteboy.admin.service;

import com.cuteboy.dao.SysUserMapper;
import com.cuteboy.dao.SysUserRoleMapper;
import com.cuteboy.entity.SysUserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserRoleService {


    @Autowired
    @Qualifier("sysUserRoleMapper")
    private SysUserRoleMapper sysUserRoleMapper;
    @Resource
    private SysRoleService sysRoleService;
    @Resource
    private SysUserService sysUserService;

    public List<SysUserRole> selectByUsername(String username){
        Example userRoleExample = new Example(SysUserRole.class);
        userRoleExample.or().andEqualTo("username", username);
        return sysUserRoleMapper.selectByExample(userRoleExample);
    }

    public void deleteByUsername(String username){
        sysUserRoleMapper.deleteByUsername(username);
    }

    public void save(SysUserRole sysUserRole){
        sysUserRoleMapper.insert(sysUserRole);
    }

}
